import request from '@/common/js/request.js'

export default {
	
	//查询文章列表
	// 条件分页查询课程列表 query条件对象{isFree: 0}，current当前页码，size每页显示多少条
	getList(query, currentPage, pageSize) {
		return request({
			url: '/api/question/list',
			method: 'GET',
			data: {
				...query,
				currentPage,
				pageSize
			} // {isFree: 0, current: current, size: size}
		})
	},
	
	//查询热门问题
	// 条件分页查询课程列表 query条件对象{isFree: 0}，current当前页码，size每页显示多少条
	getHot(currentPage, pageSize) {
		return request({
			url: '/api/question/getHot',
			method: 'GET',
			data: {
				currentPage,
				pageSize
			} // {isFree: 0, current: current, size: size}
		})
	},
	
	//查询最新问题
	// 条件分页查询课程列表 query条件对象{isFree: 0}，current当前页码，size每页显示多少条
	getNewList(currentPage, pageSize) {
		return request({
			url: '/api/question/getNew',
			method: 'GET',
			data: {
				currentPage,
				pageSize
			} // {isFree: 0, current: current, size: size}
		})
	},
	
	//查询等待回答
	// 条件分页查询课程列表 query条件对象{isFree: 0}，current当前页码，size每页显示多少条
	getWaitList(currentPage, pageSize) {
		return request({
			url: '/api/question/getWait',
			method: 'GET',
			data: {
				currentPage,
				pageSize
			} // {isFree: 0, current: current, size: size}
		})
	},
	
	//通过文章id查询文章详情页
	getQuestionById(questionId){
		return request({
			url: `/api/question/getReadList/${questionId}`,
			method: 'GET',
		})
	},
	
	//通过问题id查询回答列表
	getReplyById(questionId){
		return request({
			url: `/api/questionComment/getComment/${questionId}`,
			method: 'GET',
		})
	},
	
	//新增问题列表
	addReply(data){
		return request({
			url: `/api/questionComment`,
			method: 'POST',
			data
		})
	},
	
	starQuestion(data){
		return request({
			url: `/api/attention`,
			method: 'POST',
			data
		})
	},
	
	getStarList(data){
		return request({
			url: `/api/attention/list/${data.questionId}/${data.userId}`,
			method: 'GET',
		})
	}
	
}